package com.kcn.utils;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Properties;

public class PropertiesReader {
	private static String pfilename = "param.properties";
	private File pfile;
	private Properties pfp;
	private static PropertiesReader pReader = new PropertiesReader();

	public PropertiesReader() {
		// TODO Auto-generated constructor stub
		pfp = new Properties();

		try {
			pfp.load(new FileInputStream(this.getPfile()));
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public synchronized static PropertiesReader getPropertiesReader() {
		return pReader;
	}

	public String getProperty(String key) {
		return pfp.getProperty(key);
	}

	public File getPfile() {
		
		URI aa = null;
		try {
			aa = this.getClass().getResource("/param.properties").toURI();
		} catch (URISyntaxException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println(aa.toString());
		pfile = new File(aa);
		return pfile;
	}

	public void setPfile(File pfile) {
		this.pfile = pfile;
	}
}
